package com.comp3111.happymeal;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.user.ImageLoader;

public class MealUserCommentAdapter extends BaseAdapter {

private Activity activity;
private ArrayList <HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 

public MealUserCommentAdapter (Activity a, ArrayList <HashMap <String, String>> d) {
	activity = a;
	data=d;
	inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
	return data.size();
}

public Object getItem(int position) {
	return position;
}

public long getItemId(int position) {
	return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
	View vi=convertView;
	if(convertView==null)
		vi = inflater.inflate(R.layout.food_page_user_review_entity, null);

	ImageView list_user_image = (ImageView)vi.findViewById(R.id.list_user_image); // title
	TextView list_username = (TextView)vi.findViewById(R.id.list_username); // artist name
	TextView list_comment = (TextView)vi.findViewById(R.id.list_comment); // duration
	TextView list_time = (TextView)vi.findViewById(R.id.time); // duration
	ImageView list_love_pic=(ImageView)vi.findViewById(R.id.list_love_pic); // thumb image
	Button list_follow_btn = (Button) vi.findViewById(R.id.list_follow_btn);
	
	HashMap <String, String> mealComment = new HashMap <String, String>();
	mealComment = data.get(position);

	// Setting all values in listview
	list_username.setText(mealComment.get("userName"));
//	artist.setText(mealComment.get(FoodPageUserReviewActivity.mealName));
	list_comment.setText(mealComment.get("mealComment"));
//	imageLoader.DisplayImage(mealComment.get(FoodPageUserReviewActivity.mealCreateDate), list_user_image);
	return vi;
	}
}